package com.mimidai.application;

import android.app.Application;
import android.content.Context;

import com.zhiqianbao.utils.Constants;
import com.zhiqianbao.utils.TimeStatisticsUtil;
import com.zhiqianbao.utils.WorthPurseUtil;
import com.orm.SugarContext;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
import com.umeng.socialize.PlatformConfig;
import com.umeng.socialize.UMShareAPI;

import static android.widget.Toast.makeText;


/**
 * Created by 亮 on 2016/1/24.
 */
public class MyApplication extends Application {
    private static MyApplication mContext;
    public TimeStatisticsUtil statisticsUtil;
    public static IWXAPI mWxApi;
    @Override
    public void onCreate() {
        super.onCreate();
        mContext = this;
        //初始化各个数据库表
        WorthPurseUtil.init();
        SugarContext.init(this);
        /**引入热修复功能sdk实例化*/
        // initFotfix();
        //实例化统计页面时间工具类
        statisticsUtil = new TimeStatisticsUtil();
        CrashHandler crashHandler = CrashHandler.getInstance();
        crashHandler.init(getApplicationContext());
        UMShareAPI.get(this);//初始化sdk
        registToWX();
    }

    @Override
    public void onTerminate() {
        SugarContext.terminate();
        super.onTerminate();
    }
    private void registToWX() {
        //AppConst.WEIXIN.APP_ID是指你应用在微信开放平台上的AppID，记得替换。
        mWxApi = WXAPIFactory.createWXAPI(this, Constants.WX_ID, false);
        // 将该app注册到微信
        mWxApi.registerApp(Constants.WX_ID);
    }

    public static Context getmContext() {
        return mContext;
    }

    {
        PlatformConfig.setWeixin("wxf4bad9a50902c5b3", "c48acbe6ba241583ff754fc98c80d9b6");
        PlatformConfig.setQQZone("1105139983", "z3fvUdHMJ5fd2QWV");
        PlatformConfig.setSinaWeibo("2551077640", "e02d937640a2bd6572b19028d5bfb4e4", "http://android.myapp.com/myapp/detail.htm?apkName=com.mimidai");

    }
}
